package j05zuoye;
/*
火车票
定义一个火车票类(Ticket), 包含出发站(startStation), 到达站(stopStation), 出发时间
(startTime), 身份证号(id), 票价(price), 座位号(seat), 车次(trainNumber)属性, 火车票类包含一个打
印火车票信息的方法printTicketInfo.
 */
class Ticket{
    String startStation;
    String stopStation;
    String startTime;
    String id;
    int price;
    String seat;
    String trainNumber;

    public Ticket() {
    }

    public Ticket(String startStation, String stopStation, String startTime, String id, int price, String seat, String trainNumber) {
        this.startStation = startStation;
        this.stopStation = stopStation;
        this.startTime = startTime;
        this.id = id;
        this.price = price;
        this.seat = seat;
        this.trainNumber = trainNumber;
    }

    public void printTicketInfo(){
        String info = "";
        info += "startStation="+startStation+",";
        info += "stopStation="+stopStation;

        System.out.println("info = " + info);
    }

    //toString


    public String printTicketInfo1() {
        return "Ticket{" +
                "startStation='" + startStation + '\'' +
                ", stopStation='" + stopStation + '\'' +
                ", startTime='" + startTime + '\'' +
                ", id='" + id + '\'' +
                ", price=" + price +
                ", seat='" + seat + '\'' +
                ", trainNumber='" + trainNumber + '\'' +
                '}';
    }
}
public class J1ticket {
    public static void main(String[] args) {
        Ticket t1 = new Ticket();
        t1.printTicketInfo();
        Ticket t2 = new Ticket("郑州","大理","2024","411",32,"6车3号","k3256");
        t2.printTicketInfo();

        System.out.println(t2.toString());
        System.out.println("=====");
        //当我们打印一个对象的时候，默认自动调用toString
        System.out.println(t2);
        System.out.println(t2.printTicketInfo1());

    }
}
